package com.eliza.music.model.dao


import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.eliza.music.model.entity.Song
import kotlinx.coroutines.flow.Flow

@Dao
interface SongDao {
    @Query("SELECT * FROM song")
    suspend fun getAll(): List<Song>

    @Insert(onConflict = OnConflictStrategy.IGNORE)
    suspend fun insert(song: List<Song>)

    @Query(
        "SELECT * FROM song WHERE title LIKE :title"
    )
    fun getByTitle(title: String): Flow<List<Song>>


    @Query(
        "SELECT * FROM song WHERE id IN (:ids)"
    )
    fun getByIds(ids: Set<Int>): Flow<List<Song>>

    @Query(
        "SELECT * FROM song WHERE id = :id"
    )
    fun getById(id: Int): Flow<Song>

    @Delete()
    suspend fun deleteById(id: Song)

}